---@class RedDotsTrialHandler
RedDotsTrialHandler = {};
local this = RedDotsTrialHandler;
function RedDotsTrialHandler.init()
    --
    --CloseEvent(Config.EventType.Trials_Chaos_Info,this.update);
    --ListenEvent(Config.EventType.Trials_Chaos_Info,this.update);
    --if this.timerId then
    --    utimer.remove(this.timerId)
    --end
    --this.timerId = utimer.timeCall(this.CheckReward,1000,-1)
    CloseEvent(Config.EventType.Fresh_NewStage, this.Unlock);
    ListenEvent(Config.EventType.Fresh_NewStage, this.Unlock);
    this.hasReward = false;

    local unLockId = G.dataTable["t_global"]["128"]["f_int_value"];
    if logicMgr.MapManager.getMapId() >= unLockId then
        this.hasReward = true;
    end

    return this;
end

--
function RedDotsTrialHandler.getFlag(...)
    if logicMgr.FuncOpenManager.isOpen(Config.FuncOpenType.trials, false) then
        if logicMgr.TrialsManager.hasRedPoint() then
            return Config.RedDotsFlagState.Needful
        end
    end
    return Config.RedDotsFlagState.None;
end

function RedDotsTrialHandler.Check()
    this.hasReward = false
    RedDotsManager.addBroadcast(Config.RedDotsType.Trials);
end
function RedDotsTrialHandler.Unlock()
    local unLockId = G.dataTable["t_global"]["128"]["f_int_value"];
    if logicMgr.MapManager.getMapId() + 1 == unLockId then
        this.hasReward = true;
    end
    RedDotsManager.addBroadcast(Config.RedDotsType.Trials);
end

return RedDotsTrialHandler;